package edu.tsinghua.mrpvc.device.mobile;


import java.util.Calendar;
import java.util.Dictionary;
import java.util.Hashtable;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventConstants;
import org.osgi.service.event.EventHandler;
import edu.tsinghua.mrpvc.device.MobileDevice;
import edu.tsinghua.mrpvc.device.TvDevice;
//import edu.tsinghua.mrpvc.simulate.util.SimulateTopic;

public class Activator implements BundleActivator, EventHandler {

//	private MobileDeviceImpl mobile;
//	private final static String[] RESPONSE_TOPICS = {MobileDevice.EVENT_TOPIC_ISVALID};
	//private final static String[] SIMULATE_TOPICS = {SimulateTopic.MOBILE_CTRL_KEYBOARD, SimulateTopic.MOBILE_CTRL_MOUSE,
	//												SimulateTopic.MOBILE_CTRL_TV, SimulateTopic.MOBILE_SHARE_PATH};
	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {

//		mobile = new MobileDeviceImpl(context, "1", "1");
//		context.registerService(MobileDevice.class.getName(), mobile, null);
//		
//		Dictionary<String, Object> resProper = new Hashtable<String, Object>();
//		resProper.put(EventConstants.EVENT_TOPIC, RESPONSE_TOPICS);
//		context.registerService(EventHandler.class.getName(), mobile, resProper);
//		
		//Dictionary<String, Object> simProper = new Hashtable<String, Object>();
		//simProper.put(EventConstants.EVENT_TOPIC, SIMULATE_TOPICS);
		//context.registerService(EventHandler.class.getName(), this, simProper);
	/*	String []args={""};
		GmoteServer server = new GmoteServer();
		    GmoteServerUi ui = new GmoteServerUiWindows(server);
		    ui.sharedMain(args);
		    */
		
	}

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
	}

	@Override
	public void handleEvent(Event event) {
		// TODO Auto-generated method stub
		/*
		if(event.getTopic().equals(SimulateTopic.MOBILE_CTRL_KEYBOARD)){
			mobile.ctrlKeyBoard("right");
		}
		else if(event.getTopic().equals(SimulateTopic.MOBILE_CTRL_MOUSE)){
			String locationX = event.getProperty(TvDevice.EVENT_PROPER_LOCATION_X).toString();
			String locationY = event.getProperty(TvDevice.EVENT_PROPER_LOCATION_Y).toString();
			String action = event.getProperty(TvDevice.EVENT_PROPER_ACTION).toString();
			mobile.ctrlMouse(action, locationX, locationY);
		}
		else if(event.getTopic().equals(SimulateTopic.MOBILE_CTRL_TV)){
			mobile.ctrlTv(event.getProperty("Action").toString());
		}		
		else if(event.getTopic().equals(SimulateTopic.MOBILE_SHARE_PATH) &&
				event.getProperty(MobileDevice.EVENT_PROPER_PATH) != null){
			mobile.setSharePath(event.getProperty(MobileDevice.EVENT_PROPER_PATH).toString());
			mobile.bcSharePath();
		}
		*/
	}
}
